package com.itheima.streamdemo.myStream;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

public class MyStreamDemo05 {
    public static void main(String[] args) {
        ArrayList<Integer> list = new ArrayList<>(List.of(1, 2, 3, 4, 5, 6, 7, 8, 1, 2));

        List<Integer> list1 = list.stream().filter(s -> s % 2 == 0).collect(Collectors.toList());
        for (Integer integer : list1) {
            System.out.println("integer = " + integer);
        }
        System.out.println("====================================");

        Set<Integer> set = new HashSet<>(List.of(1, 2, 3, 4, 5, 6, 7, 8, 1, 2));
        Set<Integer> collect = set.stream().filter(s -> s % 2 == 0).collect(Collectors.toSet());
        for (Integer integer : collect) {
            System.out.println("integer = " + integer);
        }


    }
}
